#include <iostream>
#include <cmath>
#define N 100

using namespace std;

void read_matrix_a(int matrix_a[N][N], int row, int column){
int i, j;
for (i=0;i<row;i++)
    for(j=0;j<column;j++){
        cout<<"["<<i<<"]["<<j<<"]= ";
        cin>>matrix_a[i][j];}
}

void print_matrix_m(int matrix_m[N][N], int row, int column){
int i,j;
for (i=0;i<row;i++){
    for(j=0; j<column; j++)
			cout<<matrix_m[i][j]<<" ";
		cout<<endl;}
}

int main(){
int row;
int column;
int matrix_a[N][N];
int matrix_m[N][N];
int i,j,k,l;
int cnt=1;


cout<<"Type the number of rows: " ;
cin>>row;
cout<<"Type the number of columns: " ;
cin>>column;

read_matrix_a(matrix_a, row, column);
cout<<"The number of the power: ";
cin>>k;
cout<<endl;
while(cnt<k){
    for(i=0;i<row;i++)
        for(j=0;j<column;j++)
            for(l=0;l<column;++l)
                matrix_m[i][j]=matrix_a[i][l]*matrix_a[l][j];
    for(i=0;i<row;i++)
        for(j=0;j<column;j++)
            matrix_a[i][j]=matrix_m[i][j];
		++cnt;
}



cout<<"The final matrix is: "<<endl;
print_matrix_m(matrix_m, row,column);

return 0;
}
